package com.techfort.testguice;

import android.os.Parcel;
import android.os.Parcelable;

import com.techfort.tfal.rss.RssItem;

public class Book implements RssItem, Parcelable{
	private String title, description,rssurl;
	private int id;
	
	public Book(){}
	
	public Book(Parcel source){
		id = source.readInt();
		title = source.readString();
		description = source.readString();
		rssurl = source.readString();
	}
	
	@Override
	public void setId(int id) {
		this.id = id;
	}

	@Override
	public void setProperty(String propname, String propvalue) {
		if(propname.equals("title")){
			title = propvalue;
		}
		if(propname.equals("id")){
			id = Integer.parseInt(propvalue);
		}
		if(propname.equals("rssurl")){
			rssurl = propvalue;
		}
	}

	
	public String getTitle(){
		return title;
	}
	public int getId(){
		return id;
	}

	public String getRssurl(){
		return rssurl;
	}
	
	@Override
	public int describeContents() {
		return hashCode();
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		dest.writeInt(id);
		dest.writeString(title);
		dest.writeString(description);
		dest.writeString(rssurl);
	}
	
	public static final Parcelable.Creator<Book> CREATOR = new Parcelable.Creator<Book>(){

		@Override
		public Book createFromParcel(Parcel source) {
			// TODO Auto-generated method stub
			return new Book(source);
		}

		@Override
		public Book[] newArray(int size) {
			// TODO Auto-generated method stub
			return new Book[size];
		}
		
	};
	
}
